from django.db import models
from core.models import CoreModel, table_prefix
import reversion

"""产品对象"""


class Product(CoreModel):
    owner = models.ForeignKey(
        null=True,
        blank=True,
        to="sys.User",
        related_name="product_owner_set",
        on_delete=models.DO_NOTHING,
        db_constraint=False,
        verbose_name="负责人",
    )
    name = models.CharField(unique=True, max_length=128, verbose_name="产品名称")
    number = models.CharField(max_length=128, verbose_name="产品编号")
    type = models.CharField(max_length=50, default="0", verbose_name="产品类型")
    script = models.TextField(null=True, blank=True, verbose_name="执行脚本")

    def __str__(self) -> str:
        return self.name

    class Meta:
        db_table = table_prefix + "pms_product"
        verbose_name = "产品管理"
        verbose_name_plural = verbose_name
        ordering = ("-create_time",)
